Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix int overflowing in ExcelGeneralNumberFormat #1497

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Many-sun
Copy link

We're seeing this An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll Additional information: Rounding digits must be between 0 and 15, inclusive. coming from ExcelGeneralNumberFormat line 98.

This is caused by a wrong data type used in the digits counting algorithm. When calculating the len on line 96:
int len = (int)Math.Log10((**int**)Math.Abs(value)) + 1;
Casting a double to an int, you can easily end up with int overflow. When this happens, you end up with len like -2147483647.

Numbers higher than 10,000,000,000 are handled correctly line 77. But there is plenty of numbers between max int 2,147,483,647 and 10,000,000,000 that trigger the overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant